package org.cbg.control;

import org.cbg.bean.SearchMesResultBean;
import org.cbg.frame.TrslationMainJframe;
import org.cbg.panel.TraslationMyMessageJpanel;
import org.cbg.until.TraslationTableMyMessageUntil;
import org.come.action.FromServerAction;
import org.come.until.GsonUtil;

/**
 * 藏宝阁消息查询类回调
 * 
 * @author Administrator
 * 
 */
public class SearchMesResultControl implements FromServerAction {

    @Override
    public void controlMessFromServer(String mes, String type) {
        // TODO Auto-generated method stub

        // 消息处理部分(转换为对应的类)
        SearchMesResultBean sa = GsonUtil.getGsonUtil().getgson().fromJson(mes, SearchMesResultBean.class);

        // sa.getMessages()s
        /**
         * 重绘消息面板内容 最大页数赋值
         */
        TraslationMyMessageJpanel traslationMyMessageJpanel = TrslationMainJframe.getTrslationMainJframe()
                .getTrslationMainJpanel().getTranslationMainCardJpanel().getTraslationMyMessageJpanel();
        TraslationTableMyMessageUntil.TableModel(traslationMyMessageJpanel.getjScrollPane(), sa.getMessages());
        traslationMyMessageJpanel.setPage(sa.getTotal() == 0 ? 1 : sa.getTotal());
        TrslationMainJframe.getTrslationMainJframe().setXiaoxiGeshuMax(sa.getMessages().size());
        TrslationMainJframe.getTrslationMainJframe().setGoodsGouxuangeshu(0);
        /**
         * 展示当前对应面板
         */
        TrslationMainJframe
                .getTrslationMainJframe()
                .getTrslationMainJpanel()
                .getTranslationMainCardJpanel()
                .getCardLayout()
                .show(TrslationMainJframe.getTrslationMainJframe().getTrslationMainJpanel()
                        .getTranslationMainCardJpanel(), "imes");

    }

}
